
package com.feib.soeasy.job.importor;

import java.util.List;

import com.feib.soeasy.job.service.ImportService;
import com.feib.soeasy.model.ColumnValidateError;
import com.feib.soeasy.model.FormatDefinition;
import com.feib.soeasy.model.Payment;
import com.feib.soeasy.model.PaymentItem;
import com.feib.soeasy.model.UploadFile;


/**
 * @title (#)YcvsValidator.java<br>
 * @description 豫章工商 學雜費客製化檢核程式<br>
 * @author Jimmy Liu<br>
 * @version 1.0.0 2010/11/25
 * @copyright Far Eastern International Bank Copyright (c) 2010<br>
 * @2010/12/2 create by Jimmy Liu<br>
 */
public class YcvsValidator extends BasicValidator {

    /**
     * @param uploadFile
     * @param formatDefinition
     * @param columnValidateErrors
     * @param importService
     */
    public YcvsValidator(UploadFile uploadFile, FormatDefinition formatDefinition, List<ColumnValidateError> columnValidateErrors, ImportService importService) {
        super(uploadFile, formatDefinition, columnValidateErrors, importService);
    }
    
    /* (non-Javadoc)
     * @see com.feib.soeasy.job.BasicValidator#doExtraValidate(com.feib.soeasy.model.Payment, long)
     */
    @Override
    protected boolean doExtraValidate(Payment payment, long lineNumber) {
        
        // 項目名稱若為 *開頭則為不可助學貸款項目
        // 將 繳費項目 不是由*開頭，設定為不貸
        List<PaymentItem> paymentItems = payment.getPaymentItems();
        for (PaymentItem item: paymentItems)
        {
            if (null != item.getItemName() && item.getItemName().startsWith("*"))
            {
                item.setItemName(item.getItemName().substring(1));
                item.setLoanable(Boolean.TRUE);
            }
        }
        return super.doExtraValidate(payment, lineNumber);        
    }

}
